{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "file_path=\"~/Documents/Data/Full_MIMIC/\"\n",
    "\n",
    "pd.set_option('display.max_rows', 50)\n",
    "pd.set_option('display.max_columns', 300)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "adm=pd.read_csv(file_path+\"Admissions_processed.csv\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We now consider the prescriptions dataset. We select only the patients present in the cleaned admission file"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/XXXX/miniconda3/envs/pytorch/lib/python3.6/site-packages/IPython/core/interactiveshell.py:2728: DtypeWarning: Columns (11) have mixed types. Specify dtype option on import or set low_memory=False.\n",
      "  interactivity=interactivity, compiler=compiler, result=result)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of patients remaining in the database: \n",
      "21469\n"
     ]
    }
   ],
   "source": [
    "presc=pd.read_csv(file_path+\"PRESCRIPTIONS.csv\")\n",
    "\n",
    "#Restrict the dataset to the previously selected admission ids only.\n",
    "adm_ids=list(adm[\"HADM_ID\"])\n",
    "presc=presc.loc[presc[\"HADM_ID\"].isin(adm_ids)]\n",
    "\n",
    "print(\"Number of patients remaining in the database: \")\n",
    "print(presc[\"SUBJECT_ID\"].nunique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of patients remaining in the database: \n",
      "21467\n"
     ]
    }
   ],
   "source": [
    "#This part is for selecting the x most frequent prescriptions. Instead we use the list of prescriptions as in the paper.\n",
    "\n",
    "n_best=10\n",
    "#For each item, evaluate the number of patients who have been given this item.\n",
    "pat_for_item=presc.groupby(\"DRUG\")[\"SUBJECT_ID\"].nunique()\n",
    "#Order by occurence and take the 20 best (the ones with the most patients)\n",
    "frequent_labels=pat_for_item.sort_values(ascending=False)[:n_best]\n",
    "\n",
    "#Select only the time series with high occurence.\n",
    "presc2=presc.loc[presc[\"DRUG\"].isin(list(frequent_labels.index))].copy()\n",
    "\n",
    "print(\"Number of patients remaining in the database: \")\n",
    "print(presc2[\"SUBJECT_ID\"].nunique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of patients remaining in the database: \n",
      "21439\n"
     ]
    }
   ],
   "source": [
    "#Select entries whose drug name is in the list from the paper.\n",
    "drugs_list=[\"Aspirin\",\"Bisacodyl\",\"Docusate Sodium\",\"D5W\",\"Humulin-R Insulin\",\"Potassium Chloride\",\"Magnesium Sulfate\",\"Metoprolol Tartrate\",\"Sodium Chloride 0.9%  Flush\",\"Pantoprazole\"]\n",
    "presc2=presc.loc[presc[\"DRUG\"].isin(drugs_list)]\n",
    "\n",
    "print(\"Number of patients remaining in the database: \")\n",
    "print(presc2[\"SUBJECT_ID\"].nunique())\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Units Cleaning\n",
    "\n",
    "#### 1) In amounts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DRUG                         DOSE_UNIT_RX\n",
      "Aspirin                      mg              14120\n",
      "Bisacodyl                    mg              21473\n",
      "D5W                          mL              63903\n",
      "Docusate Sodium              mg              25277\n",
      "Humulin-R Insulin            UNIT             1800\n",
      "Magnesium Sulfate            gm              44053\n",
      "Metoprolol Tartrate          mg              32322\n",
      "Pantoprazole                 mg              14909\n",
      "Potassium Chloride           mEq             93649\n",
      "Sodium Chloride 0.9%  Flush  mL              41429\n",
      "Name: DOSE_UNIT_RX, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "#Verification that all input labels have the same amounts units.\n",
    "\n",
    "#Units correction\n",
    "presc2=presc2.drop(presc2.loc[presc2[\"DOSE_UNIT_RX\"].isnull()].index).copy()\n",
    "presc2=presc2.drop(presc2.loc[(presc2[\"DRUG\"]==\"Acetaminophen\")&(presc2[\"DOSE_UNIT_RX\"]!=\"mg\")].index).copy()\n",
    "presc2.loc[(presc2[\"DRUG\"]==\"D5W\")&(presc2[\"DOSE_UNIT_RX\"]==\"ml\"),\"DOSE_UNIT_RX\"]=\"mL\"\n",
    "presc2=presc2.drop(presc2.loc[(presc2[\"DRUG\"]==\"D5W\")&(presc2[\"DOSE_UNIT_RX\"]!=\"mL\")].index).copy()\n",
    "presc2=presc2.drop(presc2.loc[(presc2[\"DRUG\"]==\"Heparin\")&(presc2[\"DOSE_UNIT_RX\"]!=\"UNIT\")].index).copy()\n",
    "presc2=presc2.drop(presc2.loc[(presc2[\"DRUG\"]==\"Insulin\")&(presc2[\"DOSE_UNIT_RX\"]!=\"UNIT\")].index).copy()\n",
    "presc2=presc2.drop(presc2.loc[(presc2[\"DRUG\"]==\"Magnesium Sulfate\")&(presc2[\"DOSE_UNIT_RX\"]!=\"gm\")].index).copy()\n",
    "presc2=presc2.drop(presc2.loc[(presc2[\"DRUG\"]==\"Potassium Chloride\")&(presc2[\"DOSE_UNIT_RX\"]!=\"mEq\")].index).copy()\n",
    "presc2.loc[(presc2[\"DRUG\"]==\"Sodium Chloride 0.9%  Flush\")&(presc2[\"DOSE_UNIT_RX\"]==\"ml\"),\"DOSE_UNIT_RX\"]=\"mL\"\n",
    "presc2=presc2.drop(presc2.loc[(presc2[\"DRUG\"]==\"Bisacodyl\")&(presc2[\"DOSE_UNIT_RX\"]!=\"mg\")].index).copy()\n",
    "presc2=presc2.drop(presc2.loc[(presc2[\"DRUG\"]==\"Humulin-R Insulin\")&(presc2[\"DOSE_UNIT_RX\"]!=\"UNIT\")].index).copy()\n",
    "presc2=presc2.drop(presc2.loc[(presc2[\"DRUG\"]==\"Pantoprazole\")&(presc2[\"DOSE_UNIT_RX\"]!=\"mg\")].index).copy()\n",
    "\n",
    "\n",
    "print(presc2.groupby(\"DRUG\")[\"DOSE_UNIT_RX\"].value_counts())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Check for outliers\n",
    "\n",
    "#### 1) In amounts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lost entries in the process : -3\n"
     ]
    }
   ],
   "source": [
    "type(presc2[\"DOSE_VAL_RX\"])\n",
    "\n",
    "#We need to transform the value columns in float type.\n",
    "original_num_entries=len(presc2.index)\n",
    "#First transform the ranges (xx-yy) as the mean of the ranges.\n",
    "range_df=presc2.loc[presc2[\"DOSE_VAL_RX\"].str.contains(\"-\")].copy()\n",
    "range_df[\"First_digit\"]=range_df[\"DOSE_VAL_RX\"].str.split(\"-\").str[0].astype(float)\n",
    "range_df[\"Second_digit\"]=range_df[\"DOSE_VAL_RX\"].str.split(\"-\").str[1]\n",
    "range_df.loc[range_df[\"Second_digit\"]==\"\",'Second_digit']=range_df.loc[range_df[\"Second_digit\"]==\"\",'First_digit']\n",
    "range_df[\"Second_digit\"]=range_df[\"Second_digit\"].astype(float)\n",
    "range_df.head()\n",
    "range_df[\"mean\"]=(range_df[\"First_digit\"]+range_df[\"Second_digit\"])/2\n",
    "range_df[\"DOSE_VAL_RX\"]=range_df[\"mean\"]\n",
    "range_df.drop(columns=[\"First_digit\",\"Second_digit\",\"mean\"],inplace=True)\n",
    "\n",
    "\n",
    "#Now remove the entries with the - from the original df and force conversion to float.\n",
    "presc3=presc2.drop(presc2.loc[presc2[\"DOSE_VAL_RX\"].str.contains(\"-\")].index).copy()\n",
    "presc3[\"DOSE_VAL_RX\"]=pd.to_numeric(presc2[\"DOSE_VAL_RX\"], errors=\"coerce\")\n",
    "presc3.dropna(subset=[\"DOSE_VAL_RX\"],inplace=True)\n",
    "\n",
    "presc2=presc3.append(range_df)\n",
    "\n",
    "print(\"Lost entries in the process : {}\".format(original_num_entries-len(presc2.index)))\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ROW_ID</th>\n",
       "      <th>SUBJECT_ID</th>\n",
       "      <th>HADM_ID</th>\n",
       "      <th>ICUSTAY_ID</th>\n",
       "      <th>STARTDATE</th>\n",
       "      <th>ENDDATE</th>\n",
       "      <th>DRUG_TYPE</th>\n",
       "      <th>DRUG</th>\n",
       "      <th>DRUG_NAME_POE</th>\n",
       "      <th>DRUG_NAME_GENERIC</th>\n",
       "      <th>FORMULARY_DRUG_CD</th>\n",
       "      <th>GSN</th>\n",
       "      <th>NDC</th>\n",
       "      <th>PROD_STRENGTH</th>\n",
       "      <th>DOSE_VAL_RX</th>\n",
       "      <th>DOSE_UNIT_RX</th>\n",
       "      <th>FORM_VAL_DISP</th>\n",
       "      <th>FORM_UNIT_DISP</th>\n",
       "      <th>ROUTE</th>\n",
       "      <th>ELAPSED_TIME</th>\n",
       "      <th>ELAPSED_DAYS</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>19864</th>\n",
       "      <td>1506242</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-07</td>\n",
       "      <td>2170-10-08</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>MAGS1I</td>\n",
       "      <td>001417</td>\n",
       "      <td>5.172602e+08</td>\n",
       "      <td>1g/2mL Vial</td>\n",
       "      <td>2.0</td>\n",
       "      <td>gm</td>\n",
       "      <td>4</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19869</th>\n",
       "      <td>1507031</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-07</td>\n",
       "      <td>2170-10-12</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>D5W250</td>\n",
       "      <td>001972</td>\n",
       "      <td>3.380017e+08</td>\n",
       "      <td>250mL Bag</td>\n",
       "      <td>250.0</td>\n",
       "      <td>mL</td>\n",
       "      <td>250</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV DRIP</td>\n",
       "      <td>5 days</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19870</th>\n",
       "      <td>1507033</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-07</td>\n",
       "      <td>2170-10-12</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>DOPABASE</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>1 Bag</td>\n",
       "      <td>250.0</td>\n",
       "      <td>mL</td>\n",
       "      <td>250</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV DRIP</td>\n",
       "      <td>5 days</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19872</th>\n",
       "      <td>1507030</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-07</td>\n",
       "      <td>2170-10-12</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>D5W50</td>\n",
       "      <td>001972</td>\n",
       "      <td>3.380017e+08</td>\n",
       "      <td>50mL Bag</td>\n",
       "      <td>50.0</td>\n",
       "      <td>mL</td>\n",
       "      <td>50</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV DRIP</td>\n",
       "      <td>5 days</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19879</th>\n",
       "      <td>1507771</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-08</td>\n",
       "      <td>2170-10-09</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>KCL40I</td>\n",
       "      <td>001255</td>\n",
       "      <td>7.466530e+07</td>\n",
       "      <td>2mEq/mL-20mL</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>20</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19880</th>\n",
       "      <td>1506245</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-08</td>\n",
       "      <td>2170-10-09</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>MICROK10</td>\n",
       "      <td>001248</td>\n",
       "      <td>5.817700e+10</td>\n",
       "      <td>10mEq ER Capsule</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>4</td>\n",
       "      <td>CAP</td>\n",
       "      <td>PO</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19888</th>\n",
       "      <td>1506247</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-09</td>\n",
       "      <td>2170-10-09</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>MICROK10</td>\n",
       "      <td>001248</td>\n",
       "      <td>5.817700e+10</td>\n",
       "      <td>10mEq ER Capsule</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>4</td>\n",
       "      <td>CAP</td>\n",
       "      <td>PO</td>\n",
       "      <td>0 days</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19889</th>\n",
       "      <td>1506249</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-09</td>\n",
       "      <td>2170-10-10</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>KCL20P</td>\n",
       "      <td>001262</td>\n",
       "      <td>4.560663e+08</td>\n",
       "      <td>20mEq Packet</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>2</td>\n",
       "      <td>PKT</td>\n",
       "      <td>PO</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19893</th>\n",
       "      <td>1506248</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-09</td>\n",
       "      <td>2170-10-10</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>MAGS1I</td>\n",
       "      <td>001417</td>\n",
       "      <td>5.172602e+08</td>\n",
       "      <td>1g/2mL Vial</td>\n",
       "      <td>2.0</td>\n",
       "      <td>gm</td>\n",
       "      <td>4</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19894</th>\n",
       "      <td>1506250</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-09</td>\n",
       "      <td>2170-10-10</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>KCL20P</td>\n",
       "      <td>001262</td>\n",
       "      <td>4.560663e+08</td>\n",
       "      <td>20mEq Packet</td>\n",
       "      <td>60.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>3</td>\n",
       "      <td>PKT</td>\n",
       "      <td>PO</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19895</th>\n",
       "      <td>1506251</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-10</td>\n",
       "      <td>2170-10-11</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>MICROK10</td>\n",
       "      <td>001248</td>\n",
       "      <td>5.817700e+10</td>\n",
       "      <td>10mEq ER Capsule</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>4</td>\n",
       "      <td>CAP</td>\n",
       "      <td>PO</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19896</th>\n",
       "      <td>1506252</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-10</td>\n",
       "      <td>2170-10-11</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>KCL20P</td>\n",
       "      <td>001262</td>\n",
       "      <td>4.560663e+08</td>\n",
       "      <td>20mEq Packet</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>2</td>\n",
       "      <td>PKT</td>\n",
       "      <td>PO</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19897</th>\n",
       "      <td>1506253</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-10</td>\n",
       "      <td>2170-10-11</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>MAGS1I</td>\n",
       "      <td>001417</td>\n",
       "      <td>5.172602e+08</td>\n",
       "      <td>1g/2mL Vial</td>\n",
       "      <td>2.0</td>\n",
       "      <td>gm</td>\n",
       "      <td>4</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20524</th>\n",
       "      <td>1506256</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-11</td>\n",
       "      <td>2170-10-12</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>MICROK10</td>\n",
       "      <td>001248</td>\n",
       "      <td>5.817700e+10</td>\n",
       "      <td>10mEq ER Capsule</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>4</td>\n",
       "      <td>CAP</td>\n",
       "      <td>PO</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20526</th>\n",
       "      <td>1506257</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-11</td>\n",
       "      <td>2170-10-12</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>MAGS1I</td>\n",
       "      <td>001417</td>\n",
       "      <td>5.172602e+08</td>\n",
       "      <td>1g/2mL Vial</td>\n",
       "      <td>2.0</td>\n",
       "      <td>gm</td>\n",
       "      <td>4</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20531</th>\n",
       "      <td>1506262</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-12</td>\n",
       "      <td>2170-10-14</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>KCL20P</td>\n",
       "      <td>001262</td>\n",
       "      <td>4.560663e+08</td>\n",
       "      <td>20mEq Packet</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>2</td>\n",
       "      <td>PKT</td>\n",
       "      <td>PO</td>\n",
       "      <td>2 days</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20534</th>\n",
       "      <td>1507775</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-13</td>\n",
       "      <td>2170-10-14</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>KCL40I</td>\n",
       "      <td>001255</td>\n",
       "      <td>7.466530e+07</td>\n",
       "      <td>2mEq/mL-20mL</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>20</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20536</th>\n",
       "      <td>1507774</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-13</td>\n",
       "      <td>2170-10-14</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>MAGS1I</td>\n",
       "      <td>001417</td>\n",
       "      <td>5.172602e+08</td>\n",
       "      <td>1g/2mL Vial</td>\n",
       "      <td>4.0</td>\n",
       "      <td>gm</td>\n",
       "      <td>8</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20538</th>\n",
       "      <td>1506267</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-13</td>\n",
       "      <td>2170-10-14</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>MICROK10</td>\n",
       "      <td>001248</td>\n",
       "      <td>5.817700e+10</td>\n",
       "      <td>10mEq ER Capsule</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>4</td>\n",
       "      <td>CAP</td>\n",
       "      <td>PO</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20540</th>\n",
       "      <td>1506269</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-13</td>\n",
       "      <td>2170-10-14</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>MICROK10</td>\n",
       "      <td>001248</td>\n",
       "      <td>5.817700e+10</td>\n",
       "      <td>10mEq ER Capsule</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>4</td>\n",
       "      <td>CAP</td>\n",
       "      <td>PO</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20541</th>\n",
       "      <td>1506265</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-13</td>\n",
       "      <td>2170-10-15</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>MICROK10</td>\n",
       "      <td>001248</td>\n",
       "      <td>5.817700e+10</td>\n",
       "      <td>10mEq ER Capsule</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>4</td>\n",
       "      <td>CAP</td>\n",
       "      <td>PO</td>\n",
       "      <td>2 days</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20542</th>\n",
       "      <td>1506266</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-13</td>\n",
       "      <td>2170-10-15</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>KCL20P</td>\n",
       "      <td>001262</td>\n",
       "      <td>4.560663e+08</td>\n",
       "      <td>20mEq Packet</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>2</td>\n",
       "      <td>PKT</td>\n",
       "      <td>PO</td>\n",
       "      <td>2 days</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20544</th>\n",
       "      <td>1506276</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-14</td>\n",
       "      <td>2170-10-14</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Pantoprazole</td>\n",
       "      <td>Pantoprazole</td>\n",
       "      <td>Pantoprazole</td>\n",
       "      <td>PANT40</td>\n",
       "      <td>027462</td>\n",
       "      <td>8.084199e+06</td>\n",
       "      <td>40mg Tablet</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mg</td>\n",
       "      <td>1</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO</td>\n",
       "      <td>0 days</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20555</th>\n",
       "      <td>1507008</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-14</td>\n",
       "      <td>2170-10-16</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>NACLFLUSH</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>Syringe</td>\n",
       "      <td>3.0</td>\n",
       "      <td>mL</td>\n",
       "      <td>0.6</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IV</td>\n",
       "      <td>2 days</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20724</th>\n",
       "      <td>1507011</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-15</td>\n",
       "      <td>2170-10-15</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>MICROK10</td>\n",
       "      <td>001248</td>\n",
       "      <td>5.817700e+10</td>\n",
       "      <td>10mEq ER Capsule</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>4</td>\n",
       "      <td>CAP</td>\n",
       "      <td>PO</td>\n",
       "      <td>0 days</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20728</th>\n",
       "      <td>1507779</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-15</td>\n",
       "      <td>2170-10-16</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>KCL40I</td>\n",
       "      <td>001255</td>\n",
       "      <td>7.466530e+07</td>\n",
       "      <td>2mEq/mL-20mL</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>20</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20730</th>\n",
       "      <td>1507014</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2170-10-16</td>\n",
       "      <td>2170-10-19</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>MORPD5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>100mL Bottle</td>\n",
       "      <td>100.0</td>\n",
       "      <td>mL</td>\n",
       "      <td>1</td>\n",
       "      <td>BTL</td>\n",
       "      <td>IV DRIP</td>\n",
       "      <td>3 days</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23078</th>\n",
       "      <td>1507762</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-07</td>\n",
       "      <td>2170-10-08</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>KCL20PM</td>\n",
       "      <td>045309</td>\n",
       "      <td>3.380703e+08</td>\n",
       "      <td>20mEq/50mL Premix</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>2</td>\n",
       "      <td>BAG</td>\n",
       "      <td>IV</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23079</th>\n",
       "      <td>1507766</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-07</td>\n",
       "      <td>2170-10-08</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Potassium Chloride</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>KCL20PM</td>\n",
       "      <td>045309</td>\n",
       "      <td>3.380703e+08</td>\n",
       "      <td>20mEq/50mL Premix</td>\n",
       "      <td>40.0</td>\n",
       "      <td>mEq</td>\n",
       "      <td>2</td>\n",
       "      <td>BAG</td>\n",
       "      <td>IV</td>\n",
       "      <td>1 days</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25414</th>\n",
       "      <td>1517313</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2170-10-06</td>\n",
       "      <td>2170-10-19</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Bisacodyl</td>\n",
       "      <td>Bisacodyl</td>\n",
       "      <td>Bisacodyl</td>\n",
       "      <td>BISA5</td>\n",
       "      <td>002947</td>\n",
       "      <td>5.295907e+10</td>\n",
       "      <td>5 mg Tab</td>\n",
       "      <td>10.0</td>\n",
       "      <td>mg</td>\n",
       "      <td>2</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO</td>\n",
       "      <td>13 days</td>\n",
       "      <td>13.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25415</th>\n",
       "      <td>1517314</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2170-10-06</td>\n",
       "      <td>2170-10-19</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Bisacodyl</td>\n",
       "      <td>Bisacodyl</td>\n",
       "      <td>Bisacodyl (Rectal)</td>\n",
       "      <td>BISA10R</td>\n",
       "      <td>002944</td>\n",
       "      <td>5.456919e+10</td>\n",
       "      <td>10 mg Supp</td>\n",
       "      <td>10.0</td>\n",
       "      <td>mg</td>\n",
       "      <td>1</td>\n",
       "      <td>SUPP</td>\n",
       "      <td>PR</td>\n",
       "      <td>13 days</td>\n",
       "      <td>13.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25417</th>\n",
       "      <td>1507026</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-07</td>\n",
       "      <td>2170-10-07</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>DOPABASE</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>1 Bag</td>\n",
       "      <td>250.0</td>\n",
       "      <td>mL</td>\n",
       "      <td>250</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV DRIP</td>\n",
       "      <td>0 days</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25418</th>\n",
       "      <td>1507027</td>\n",
       "      <td>275</td>\n",
       "      <td>129886</td>\n",
       "      <td>219649.0</td>\n",
       "      <td>2170-10-07</td>\n",
       "      <td>2170-10-07</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>D5W250</td>\n",
       "      <td>001972</td>\n",
       "      <td>3.380017e+08</td>\n",
       "      <td>250mL Bag</td>\n",
       "      <td>250.0</td>\n",
       "      <td>mL</td>\n",
       "      <td>250</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV DRIP</td>\n",
       "      <td>0 days</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        ROW_ID  SUBJECT_ID  HADM_ID  ICUSTAY_ID  STARTDATE    ENDDATE  \\\n",
       "19864  1506242         275   129886    219649.0 2170-10-07 2170-10-08   \n",
       "19869  1507031         275   129886    219649.0 2170-10-07 2170-10-12   \n",
       "19870  1507033         275   129886    219649.0 2170-10-07 2170-10-12   \n",
       "19872  1507030         275   129886    219649.0 2170-10-07 2170-10-12   \n",
       "19879  1507771         275   129886    219649.0 2170-10-08 2170-10-09   \n",
       "19880  1506245         275   129886    219649.0 2170-10-08 2170-10-09   \n",
       "19888  1506247         275   129886    219649.0 2170-10-09 2170-10-09   \n",
       "19889  1506249         275   129886    219649.0 2170-10-09 2170-10-10   \n",
       "19893  1506248         275   129886    219649.0 2170-10-09 2170-10-10   \n",
       "19894  1506250         275   129886    219649.0 2170-10-09 2170-10-10   \n",
       "19895  1506251         275   129886    219649.0 2170-10-10 2170-10-11   \n",
       "19896  1506252         275   129886    219649.0 2170-10-10 2170-10-11   \n",
       "19897  1506253         275   129886    219649.0 2170-10-10 2170-10-11   \n",
       "20524  1506256         275   129886    219649.0 2170-10-11 2170-10-12   \n",
       "20526  1506257         275   129886    219649.0 2170-10-11 2170-10-12   \n",
       "20531  1506262         275   129886    219649.0 2170-10-12 2170-10-14   \n",
       "20534  1507775         275   129886    219649.0 2170-10-13 2170-10-14   \n",
       "20536  1507774         275   129886    219649.0 2170-10-13 2170-10-14   \n",
       "20538  1506267         275   129886    219649.0 2170-10-13 2170-10-14   \n",
       "20540  1506269         275   129886    219649.0 2170-10-13 2170-10-14   \n",
       "20541  1506265         275   129886    219649.0 2170-10-13 2170-10-15   \n",
       "20542  1506266         275   129886    219649.0 2170-10-13 2170-10-15   \n",
       "20544  1506276         275   129886    219649.0 2170-10-14 2170-10-14   \n",
       "20555  1507008         275   129886    219649.0 2170-10-14 2170-10-16   \n",
       "20724  1507011         275   129886    219649.0 2170-10-15 2170-10-15   \n",
       "20728  1507779         275   129886    219649.0 2170-10-15 2170-10-16   \n",
       "20730  1507014         275   129886         NaN 2170-10-16 2170-10-19   \n",
       "23078  1507762         275   129886    219649.0 2170-10-07 2170-10-08   \n",
       "23079  1507766         275   129886    219649.0 2170-10-07 2170-10-08   \n",
       "25414  1517313         275   129886         NaN 2170-10-06 2170-10-19   \n",
       "25415  1517314         275   129886         NaN 2170-10-06 2170-10-19   \n",
       "25417  1507026         275   129886    219649.0 2170-10-07 2170-10-07   \n",
       "25418  1507027         275   129886    219649.0 2170-10-07 2170-10-07   \n",
       "\n",
       "      DRUG_TYPE                         DRUG                DRUG_NAME_POE  \\\n",
       "19864      MAIN            Magnesium Sulfate            Magnesium Sulfate   \n",
       "19869      BASE                          D5W                          NaN   \n",
       "19870      BASE                          D5W                          NaN   \n",
       "19872      BASE                          D5W                          NaN   \n",
       "19879      MAIN           Potassium Chloride                          NaN   \n",
       "19880      MAIN           Potassium Chloride           Potassium Chloride   \n",
       "19888      MAIN           Potassium Chloride           Potassium Chloride   \n",
       "19889      MAIN           Potassium Chloride           Potassium Chloride   \n",
       "19893      MAIN            Magnesium Sulfate            Magnesium Sulfate   \n",
       "19894      MAIN           Potassium Chloride           Potassium Chloride   \n",
       "19895      MAIN           Potassium Chloride           Potassium Chloride   \n",
       "19896      MAIN           Potassium Chloride           Potassium Chloride   \n",
       "19897      MAIN            Magnesium Sulfate            Magnesium Sulfate   \n",
       "20524      MAIN           Potassium Chloride           Potassium Chloride   \n",
       "20526      MAIN            Magnesium Sulfate            Magnesium Sulfate   \n",
       "20531      MAIN           Potassium Chloride           Potassium Chloride   \n",
       "20534      MAIN           Potassium Chloride                          NaN   \n",
       "20536      MAIN            Magnesium Sulfate                          NaN   \n",
       "20538      MAIN           Potassium Chloride           Potassium Chloride   \n",
       "20540      MAIN           Potassium Chloride           Potassium Chloride   \n",
       "20541      MAIN           Potassium Chloride           Potassium Chloride   \n",
       "20542      MAIN           Potassium Chloride           Potassium Chloride   \n",
       "20544      MAIN                 Pantoprazole                 Pantoprazole   \n",
       "20555      MAIN  Sodium Chloride 0.9%  Flush  Sodium Chloride 0.9%  Flush   \n",
       "20724      MAIN           Potassium Chloride           Potassium Chloride   \n",
       "20728      MAIN           Potassium Chloride                          NaN   \n",
       "20730      BASE                          D5W                          NaN   \n",
       "23078      MAIN           Potassium Chloride                          NaN   \n",
       "23079      MAIN           Potassium Chloride                          NaN   \n",
       "25414      MAIN                    Bisacodyl                    Bisacodyl   \n",
       "25415      MAIN                    Bisacodyl                    Bisacodyl   \n",
       "25417      BASE                          D5W                          NaN   \n",
       "25418      BASE                          D5W                          NaN   \n",
       "\n",
       "                 DRUG_NAME_GENERIC FORMULARY_DRUG_CD     GSN           NDC  \\\n",
       "19864            Magnesium Sulfate            MAGS1I  001417  5.172602e+08   \n",
       "19869                          NaN            D5W250  001972  3.380017e+08   \n",
       "19870                          NaN          DOPABASE     NaN  0.000000e+00   \n",
       "19872                          NaN             D5W50  001972  3.380017e+08   \n",
       "19879                          NaN            KCL40I  001255  7.466530e+07   \n",
       "19880           Potassium Chloride          MICROK10  001248  5.817700e+10   \n",
       "19888           Potassium Chloride          MICROK10  001248  5.817700e+10   \n",
       "19889           Potassium Chloride            KCL20P  001262  4.560663e+08   \n",
       "19893            Magnesium Sulfate            MAGS1I  001417  5.172602e+08   \n",
       "19894           Potassium Chloride            KCL20P  001262  4.560663e+08   \n",
       "19895           Potassium Chloride          MICROK10  001248  5.817700e+10   \n",
       "19896           Potassium Chloride            KCL20P  001262  4.560663e+08   \n",
       "19897            Magnesium Sulfate            MAGS1I  001417  5.172602e+08   \n",
       "20524           Potassium Chloride          MICROK10  001248  5.817700e+10   \n",
       "20526            Magnesium Sulfate            MAGS1I  001417  5.172602e+08   \n",
       "20531           Potassium Chloride            KCL20P  001262  4.560663e+08   \n",
       "20534                          NaN            KCL40I  001255  7.466530e+07   \n",
       "20536                          NaN            MAGS1I  001417  5.172602e+08   \n",
       "20538           Potassium Chloride          MICROK10  001248  5.817700e+10   \n",
       "20540           Potassium Chloride          MICROK10  001248  5.817700e+10   \n",
       "20541           Potassium Chloride          MICROK10  001248  5.817700e+10   \n",
       "20542           Potassium Chloride            KCL20P  001262  4.560663e+08   \n",
       "20544                 Pantoprazole            PANT40  027462  8.084199e+06   \n",
       "20555  Sodium Chloride 0.9%  Flush         NACLFLUSH     NaN  0.000000e+00   \n",
       "20724           Potassium Chloride          MICROK10  001248  5.817700e+10   \n",
       "20728                          NaN            KCL40I  001255  7.466530e+07   \n",
       "20730                          NaN           MORPD5W     NaN  0.000000e+00   \n",
       "23078                          NaN           KCL20PM  045309  3.380703e+08   \n",
       "23079                          NaN           KCL20PM  045309  3.380703e+08   \n",
       "25414                    Bisacodyl             BISA5  002947  5.295907e+10   \n",
       "25415           Bisacodyl (Rectal)           BISA10R  002944  5.456919e+10   \n",
       "25417                          NaN          DOPABASE     NaN  0.000000e+00   \n",
       "25418                          NaN            D5W250  001972  3.380017e+08   \n",
       "\n",
       "           PROD_STRENGTH  DOSE_VAL_RX DOSE_UNIT_RX FORM_VAL_DISP  \\\n",
       "19864        1g/2mL Vial          2.0           gm             4   \n",
       "19869          250mL Bag        250.0           mL           250   \n",
       "19870              1 Bag        250.0           mL           250   \n",
       "19872           50mL Bag         50.0           mL            50   \n",
       "19879       2mEq/mL-20mL         40.0          mEq            20   \n",
       "19880   10mEq ER Capsule         40.0          mEq             4   \n",
       "19888   10mEq ER Capsule         40.0          mEq             4   \n",
       "19889       20mEq Packet         40.0          mEq             2   \n",
       "19893        1g/2mL Vial          2.0           gm             4   \n",
       "19894       20mEq Packet         60.0          mEq             3   \n",
       "19895   10mEq ER Capsule         40.0          mEq             4   \n",
       "19896       20mEq Packet         40.0          mEq             2   \n",
       "19897        1g/2mL Vial          2.0           gm             4   \n",
       "20524   10mEq ER Capsule         40.0          mEq             4   \n",
       "20526        1g/2mL Vial          2.0           gm             4   \n",
       "20531       20mEq Packet         40.0          mEq             2   \n",
       "20534       2mEq/mL-20mL         40.0          mEq            20   \n",
       "20536        1g/2mL Vial          4.0           gm             8   \n",
       "20538   10mEq ER Capsule         40.0          mEq             4   \n",
       "20540   10mEq ER Capsule         40.0          mEq             4   \n",
       "20541   10mEq ER Capsule         40.0          mEq             4   \n",
       "20542       20mEq Packet         40.0          mEq             2   \n",
       "20544        40mg Tablet         40.0           mg             1   \n",
       "20555            Syringe          3.0           mL           0.6   \n",
       "20724   10mEq ER Capsule         40.0          mEq             4   \n",
       "20728       2mEq/mL-20mL         40.0          mEq            20   \n",
       "20730       100mL Bottle        100.0           mL             1   \n",
       "23078  20mEq/50mL Premix         40.0          mEq             2   \n",
       "23079  20mEq/50mL Premix         40.0          mEq             2   \n",
       "25414           5 mg Tab         10.0           mg             2   \n",
       "25415         10 mg Supp         10.0           mg             1   \n",
       "25417              1 Bag        250.0           mL           250   \n",
       "25418          250mL Bag        250.0           mL           250   \n",
       "\n",
       "      FORM_UNIT_DISP    ROUTE ELAPSED_TIME  ELAPSED_DAYS  \n",
       "19864             ml       IV       1 days           1.0  \n",
       "19869             ml  IV DRIP       5 days           5.0  \n",
       "19870             ml  IV DRIP       5 days           5.0  \n",
       "19872             ml  IV DRIP       5 days           5.0  \n",
       "19879             ml       IV       1 days           1.0  \n",
       "19880            CAP       PO       1 days           1.0  \n",
       "19888            CAP       PO       0 days           0.0  \n",
       "19889            PKT       PO       1 days           1.0  \n",
       "19893             ml       IV       1 days           1.0  \n",
       "19894            PKT       PO       1 days           1.0  \n",
       "19895            CAP       PO       1 days           1.0  \n",
       "19896            PKT       PO       1 days           1.0  \n",
       "19897             ml       IV       1 days           1.0  \n",
       "20524            CAP       PO       1 days           1.0  \n",
       "20526             ml       IV       1 days           1.0  \n",
       "20531            PKT       PO       2 days           2.0  \n",
       "20534             ml       IV       1 days           1.0  \n",
       "20536             ml       IV       1 days           1.0  \n",
       "20538            CAP       PO       1 days           1.0  \n",
       "20540            CAP       PO       1 days           1.0  \n",
       "20541            CAP       PO       2 days           2.0  \n",
       "20542            PKT       PO       2 days           2.0  \n",
       "20544            TAB       PO       0 days           0.0  \n",
       "20555            SYR       IV       2 days           2.0  \n",
       "20724            CAP       PO       0 days           0.0  \n",
       "20728             ml       IV       1 days           1.0  \n",
       "20730            BTL  IV DRIP       3 days           3.0  \n",
       "23078            BAG       IV       1 days           1.0  \n",
       "23079            BAG       IV       1 days           1.0  \n",
       "25414            TAB       PO      13 days          13.0  \n",
       "25415           SUPP       PR      13 days          13.0  \n",
       "25417             ml  IV DRIP       0 days           0.0  \n",
       "25418             ml  IV DRIP       0 days           0.0  "
      ]
     },
     "execution_count": 122,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "presc2.loc[presc2[\"SUBJECT_ID\"]==275]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>min</th>\n",
       "      <th>25%</th>\n",
       "      <th>50%</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>DRUG</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Aspirin</th>\n",
       "      <td>14120.0</td>\n",
       "      <td>192.283538</td>\n",
       "      <td>121.424018</td>\n",
       "      <td>0.0</td>\n",
       "      <td>81.0</td>\n",
       "      <td>81.0</td>\n",
       "      <td>325.0</td>\n",
       "      <td>975.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Bisacodyl</th>\n",
       "      <td>21472.0</td>\n",
       "      <td>10.108397</td>\n",
       "      <td>15.019865</td>\n",
       "      <td>5.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>2210.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D5W</th>\n",
       "      <td>63901.0</td>\n",
       "      <td>270.993504</td>\n",
       "      <td>215.528569</td>\n",
       "      <td>0.0</td>\n",
       "      <td>250.0</td>\n",
       "      <td>250.0</td>\n",
       "      <td>250.0</td>\n",
       "      <td>3250.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Docusate Sodium</th>\n",
       "      <td>25277.0</td>\n",
       "      <td>100.975195</td>\n",
       "      <td>10.284491</td>\n",
       "      <td>100.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>400.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Humulin-R Insulin</th>\n",
       "      <td>1800.0</td>\n",
       "      <td>100.461944</td>\n",
       "      <td>14.505230</td>\n",
       "      <td>1.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>500.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Magnesium Sulfate</th>\n",
       "      <td>44053.0</td>\n",
       "      <td>2.504125</td>\n",
       "      <td>0.842145</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Metoprolol Tartrate</th>\n",
       "      <td>32322.0</td>\n",
       "      <td>23.229793</td>\n",
       "      <td>22.852314</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>12.5</td>\n",
       "      <td>25.0</td>\n",
       "      <td>200.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Pantoprazole</th>\n",
       "      <td>14909.0</td>\n",
       "      <td>41.473204</td>\n",
       "      <td>7.654519</td>\n",
       "      <td>0.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>120.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Potassium Chloride</th>\n",
       "      <td>93649.0</td>\n",
       "      <td>36.592713</td>\n",
       "      <td>15.761304</td>\n",
       "      <td>0.0</td>\n",
       "      <td>20.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>420.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Sodium Chloride 0.9%  Flush</th>\n",
       "      <td>41429.0</td>\n",
       "      <td>4.016498</td>\n",
       "      <td>2.565794</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>150.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                               count        mean         std    min    25%  \\\n",
       "DRUG                                                                         \n",
       "Aspirin                      14120.0  192.283538  121.424018    0.0   81.0   \n",
       "Bisacodyl                    21472.0   10.108397   15.019865    5.0   10.0   \n",
       "D5W                          63901.0  270.993504  215.528569    0.0  250.0   \n",
       "Docusate Sodium              25277.0  100.975195   10.284491  100.0  100.0   \n",
       "Humulin-R Insulin             1800.0  100.461944   14.505230    1.0  100.0   \n",
       "Magnesium Sulfate            44053.0    2.504125    0.842145    0.0    2.0   \n",
       "Metoprolol Tartrate          32322.0   23.229793   22.852314    0.0    5.0   \n",
       "Pantoprazole                 14909.0   41.473204    7.654519    0.0   40.0   \n",
       "Potassium Chloride           93649.0   36.592713   15.761304    0.0   20.0   \n",
       "Sodium Chloride 0.9%  Flush  41429.0    4.016498    2.565794    1.0    3.0   \n",
       "\n",
       "                               50%    75%     max  \n",
       "DRUG                                               \n",
       "Aspirin                       81.0  325.0   975.0  \n",
       "Bisacodyl                     10.0   10.0  2210.0  \n",
       "D5W                          250.0  250.0  3250.0  \n",
       "Docusate Sodium              100.0  100.0   400.0  \n",
       "Humulin-R Insulin            100.0  100.0   500.0  \n",
       "Magnesium Sulfate              2.0    3.0    20.0  \n",
       "Metoprolol Tartrate           12.5   25.0   200.0  \n",
       "Pantoprazole                  40.0   40.0   120.0  \n",
       "Potassium Chloride            40.0   40.0   420.0  \n",
       "Sodium Chloride 0.9%  Flush    3.0    3.0   150.0  "
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "presc2.groupby(\"DRUG\")[\"DOSE_VAL_RX\"].describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of patients remaining in the database: \n",
      "21439\n",
      "Number of datapoints remaining in the database: \n",
      "351883\n"
     ]
    }
   ],
   "source": [
    "#Remove all entries whose rate is more than 4 std away from the mean.\n",
    "presc_desc=presc2.groupby(\"DRUG\")[\"DOSE_VAL_RX\"].describe()\n",
    "name_list=list(presc_desc.loc[presc_desc[\"count\"]!=0].index)\n",
    "for label in name_list:\n",
    "    presc2=presc2.drop(presc2.loc[(presc2[\"DRUG\"]==label)&(presc2[\"DOSE_VAL_RX\"]>(presc_desc.loc[label,\"mean\"]+4*presc_desc.loc[label,\"std\"]))].index).copy()\n",
    "\n",
    "print(\"Number of patients remaining in the database: \")\n",
    "print(presc2[\"SUBJECT_ID\"].nunique())\n",
    "print(\"Number of datapoints remaining in the database: \")\n",
    "print(len(presc2.index))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>min</th>\n",
       "      <th>25%</th>\n",
       "      <th>50%</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>DRUG</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Aspirin</th>\n",
       "      <td>14119.0</td>\n",
       "      <td>192.228100</td>\n",
       "      <td>121.249490</td>\n",
       "      <td>0.0</td>\n",
       "      <td>81.0</td>\n",
       "      <td>81.0</td>\n",
       "      <td>325.0</td>\n",
       "      <td>650.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Bisacodyl</th>\n",
       "      <td>21471.0</td>\n",
       "      <td>10.005938</td>\n",
       "      <td>0.433274</td>\n",
       "      <td>5.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>40.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D5W</th>\n",
       "      <td>63859.0</td>\n",
       "      <td>269.222128</td>\n",
       "      <td>204.110200</td>\n",
       "      <td>0.0</td>\n",
       "      <td>250.0</td>\n",
       "      <td>250.0</td>\n",
       "      <td>250.0</td>\n",
       "      <td>1000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Docusate Sodium</th>\n",
       "      <td>25040.0</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>100.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Humulin-R Insulin</th>\n",
       "      <td>1789.0</td>\n",
       "      <td>99.570430</td>\n",
       "      <td>6.192594</td>\n",
       "      <td>1.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Magnesium Sulfate</th>\n",
       "      <td>44037.0</td>\n",
       "      <td>2.502082</td>\n",
       "      <td>0.830932</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Metoprolol Tartrate</th>\n",
       "      <td>32163.0</td>\n",
       "      <td>22.620974</td>\n",
       "      <td>21.136326</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>12.5</td>\n",
       "      <td>25.0</td>\n",
       "      <td>100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Pantoprazole</th>\n",
       "      <td>14352.0</td>\n",
       "      <td>39.975195</td>\n",
       "      <td>0.827762</td>\n",
       "      <td>0.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>40.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Potassium Chloride</th>\n",
       "      <td>93626.0</td>\n",
       "      <td>36.565601</td>\n",
       "      <td>15.587203</td>\n",
       "      <td>0.0</td>\n",
       "      <td>20.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>90.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Sodium Chloride 0.9%  Flush</th>\n",
       "      <td>41427.0</td>\n",
       "      <td>4.012588</td>\n",
       "      <td>2.462315</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                               count        mean         std    min    25%  \\\n",
       "DRUG                                                                         \n",
       "Aspirin                      14119.0  192.228100  121.249490    0.0   81.0   \n",
       "Bisacodyl                    21471.0   10.005938    0.433274    5.0   10.0   \n",
       "D5W                          63859.0  269.222128  204.110200    0.0  250.0   \n",
       "Docusate Sodium              25040.0  100.000000    0.000000  100.0  100.0   \n",
       "Humulin-R Insulin             1789.0   99.570430    6.192594    1.0  100.0   \n",
       "Magnesium Sulfate            44037.0    2.502082    0.830932    0.0    2.0   \n",
       "Metoprolol Tartrate          32163.0   22.620974   21.136326    0.0    5.0   \n",
       "Pantoprazole                 14352.0   39.975195    0.827762    0.0   40.0   \n",
       "Potassium Chloride           93626.0   36.565601   15.587203    0.0   20.0   \n",
       "Sodium Chloride 0.9%  Flush  41427.0    4.012588    2.462315    1.0    3.0   \n",
       "\n",
       "                               50%    75%     max  \n",
       "DRUG                                               \n",
       "Aspirin                       81.0  325.0   650.0  \n",
       "Bisacodyl                     10.0   10.0    40.0  \n",
       "D5W                          250.0  250.0  1000.0  \n",
       "Docusate Sodium              100.0  100.0   100.0  \n",
       "Humulin-R Insulin            100.0  100.0   100.0  \n",
       "Magnesium Sulfate              2.0    3.0     5.0  \n",
       "Metoprolol Tartrate           12.5   25.0   100.0  \n",
       "Pantoprazole                  40.0   40.0    40.0  \n",
       "Potassium Chloride            40.0   40.0    90.0  \n",
       "Sodium Chloride 0.9%  Flush    3.0    3.0    10.0  "
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "presc2.groupby(\"DRUG\")[\"DOSE_VAL_RX\"].describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "metadata": {},
   "outputs": [],
   "source": [
    "presc2['CHARTTIME']=pd.to_datetime(presc2[\"STARTDATE\"], format='%Y-%m-%d %H:%M:%S')\n",
    "\n",
    "#To avoid confounding labels with labels from other tables, we add \"drug\" to the name\n",
    "presc2[\"DRUG\"]=presc2[\"DRUG\"]+\" Drug\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "metadata": {},
   "outputs": [],
   "source": [
    "presc2.to_csv(file_path+\"PRESCRIPTIONS_processed.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAD8CAYAAACLrvgBAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAF7hJREFUeJzt3X+s3XWd5/Hna1txXR2XIoU0tN2i25mIZLZCg01cDSsKBTdT3MgsZFc6LknVhUSz84fV/QNWJcHZVTck2kkdGsrEobAg0ox1scsyw5oAUgT5ITK9ICPXNm2liBhmMcX3/nE+dz1czr3323svnHPl+Ui+Od/z/n4+3+/nnFz64vv5fs85qSokSeriHw17AJKkhcPQkCR1ZmhIkjozNCRJnRkakqTODA1JUmeGhiSpM0NDktSZoSFJ6mzxsAcw344//vhatWrVsIchSQvKfffd9/OqWjpTu9+50Fi1ahV79uwZ9jAkaUFJ8vdd2jk9JUnqzNCQJHVmaEiSOjM0JEmdzRgaSVYkuSPJo0keSfLJVj8uye4ke9vjklZPkquTjCV5MMlpffva2NrvTbKxr356kodan6uTZLpjSJKGo8uZxhHgT6vq7cA64NIkpwCbgdurajVwe3sOcC6wui2bgC3QCwDgcuBdwBnA5X0hsKW1nei3vtWnOoYkaQhmDI2q2l9VP2jrzwGPAicBG4Dtrdl24Py2vgG4rnruBo5Nsgw4B9hdVYer6hlgN7C+bXtzVd1VvZ8RvG7SvgYdQ5I0BEd1TSPJKuCdwD3AiVW1H3rBApzQmp0EPNXXbbzVpquPD6gzzTEkSUPQOTSSvAm4GfhUVf1yuqYDajW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"output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       " 1.0     135008\n",
       " 0.0      63660\n",
       " 2.0      39139\n",
       " 3.0      31255\n",
       " 4.0      21395\n",
       " 5.0      14962\n",
       " 6.0      10840\n",
       " 7.0       7600\n",
       " 8.0       5703\n",
       " 9.0       4229\n",
       " 10.0      3496\n",
       " 11.0      2686\n",
       " 12.0      2177\n",
       " 13.0      1937\n",
       " 14.0      1467\n",
       " 15.0      1215\n",
       " 16.0       957\n",
       " 17.0       874\n",
       " 18.0       677\n",
       "-1.0        551\n",
       " 19.0       542\n",
       " 20.0       492\n",
       " 21.0       400\n",
       " 22.0       337\n",
       " 23.0       281\n",
       " 25.0       246\n",
       " 24.0       234\n",
       " 27.0       126\n",
       " 26.0       123\n",
       " 28.0        92\n",
       " 29.0        44\n",
       " 30.0        14\n",
       "-2.0          7\n",
       "-4.0          1\n",
       "-5.0          1\n",
       "Name: ELAPSED_DAYS, dtype: int64"
      ]
     },
     "execution_count": 112,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "presc2['STARTDATE']=pd.to_datetime(presc2[\"STARTDATE\"], format='%Y-%m-%d %H:%M:%S')\n",
    "presc2['ENDDATE']=pd.to_datetime(presc2[\"ENDDATE\"], format='%Y-%m-%d %H:%M:%S')\n",
    "\n",
    "presc2[\"ELAPSED_TIME\"]=(presc2[\"ENDDATE\"]-presc2[\"STARTDATE\"])\n",
    "presc2[\"ELAPSED_DAYS\"]=presc2[\"ELAPSED_TIME\"].dt.days\n",
    "plt.hist(presc2.loc[(presc2[\"ELAPSED_DAYS\"].notnull()),\"ELAPSED_DAYS\"])\n",
    "plt.show()\n",
    "\n",
    "presc2.loc[(presc2[\"ELAPSED_DAYS\"].notnull()),\"ELAPSED_DAYS\"].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ROW_ID</th>\n",
       "      <th>SUBJECT_ID</th>\n",
       "      <th>HADM_ID</th>\n",
       "      <th>ICUSTAY_ID</th>\n",
       "      <th>STARTDATE</th>\n",
       "      <th>ENDDATE</th>\n",
       "      <th>DRUG_TYPE</th>\n",
       "      <th>DRUG</th>\n",
       "      <th>DRUG_NAME_POE</th>\n",
       "      <th>DRUG_NAME_GENERIC</th>\n",
       "      <th>FORMULARY_DRUG_CD</th>\n",
       "      <th>GSN</th>\n",
       "      <th>NDC</th>\n",
       "      <th>PROD_STRENGTH</th>\n",
       "      <th>DOSE_VAL_RX</th>\n",
       "      <th>DOSE_UNIT_RX</th>\n",
       "      <th>FORM_VAL_DISP</th>\n",
       "      <th>FORM_UNIT_DISP</th>\n",
       "      <th>ROUTE</th>\n",
       "      <th>ELAPSED_TIME</th>\n",
       "      <th>ELAPSED_DAYS</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>34263</th>\n",
       "      <td>1235214</td>\n",
       "      <td>458</td>\n",
       "      <td>183288</td>\n",
       "      <td>279940.0</td>\n",
       "      <td>2152-01-24</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Insulin</td>\n",
       "      <td>Insulin</td>\n",
       "      <td>Insulin</td>\n",
       "      <td>INSULIN</td>\n",
       "      <td>001723</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>Dummy Pkg for POE pump and PHA SS ordering</td>\n",
       "      <td>0</td>\n",
       "      <td>UNIT</td>\n",
       "      <td>00</td>\n",
       "      <td>VIAL</td>\n",
       "      <td>SC</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34264</th>\n",
       "      <td>1235208</td>\n",
       "      <td>458</td>\n",
       "      <td>183288</td>\n",
       "      <td>279940.0</td>\n",
       "      <td>2152-01-24</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Insulin</td>\n",
       "      <td>Insulin</td>\n",
       "      <td>Insulin</td>\n",
       "      <td>INSULIN</td>\n",
       "      <td>001723</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>Dummy Pkg for POE pump and PHA SS ordering</td>\n",
       "      <td>0</td>\n",
       "      <td>UNIT</td>\n",
       "      <td>00</td>\n",
       "      <td>VIAL</td>\n",
       "      <td>SC</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>71447</th>\n",
       "      <td>1926835</td>\n",
       "      <td>979</td>\n",
       "      <td>163886</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2163-02-25</td>\n",
       "      <td>NaT</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>CLINBASE</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>50ML BAG</td>\n",
       "      <td>50</td>\n",
       "      <td>mL</td>\n",
       "      <td>1</td>\n",
       "      <td>BAG</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>95226</th>\n",
       "      <td>1703181</td>\n",
       "      <td>1311</td>\n",
       "      <td>173933</td>\n",
       "      <td>210824.0</td>\n",
       "      <td>2180-12-25</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Morphine Sulfate</td>\n",
       "      <td>Morphine Sulfate</td>\n",
       "      <td>Morphine Sulfate</td>\n",
       "      <td>MORP4I</td>\n",
       "      <td>004072</td>\n",
       "      <td>7.412580e+07</td>\n",
       "      <td>4mg Syringe</td>\n",
       "      <td>2-5</td>\n",
       "      <td>mg</td>\n",
       "      <td>0.5-1.25</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96026</th>\n",
       "      <td>599638</td>\n",
       "      <td>1329</td>\n",
       "      <td>139888</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2152-09-19</td>\n",
       "      <td>NaT</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>HEPBASE</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>HEPARIN BASE</td>\n",
       "      <td>250</td>\n",
       "      <td>mL</td>\n",
       "      <td>250</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96824</th>\n",
       "      <td>599648</td>\n",
       "      <td>1329</td>\n",
       "      <td>139888</td>\n",
       "      <td>297865.0</td>\n",
       "      <td>2152-09-22</td>\n",
       "      <td>NaT</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>D5W100</td>\n",
       "      <td>001972</td>\n",
       "      <td>3.380017e+08</td>\n",
       "      <td>100ML BAG</td>\n",
       "      <td>100</td>\n",
       "      <td>mL</td>\n",
       "      <td>100</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96867</th>\n",
       "      <td>599657</td>\n",
       "      <td>1329</td>\n",
       "      <td>139888</td>\n",
       "      <td>295636.0</td>\n",
       "      <td>2152-09-26</td>\n",
       "      <td>NaT</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>D5W100</td>\n",
       "      <td>001972</td>\n",
       "      <td>3.380017e+08</td>\n",
       "      <td>100ML BAG</td>\n",
       "      <td>100</td>\n",
       "      <td>mL</td>\n",
       "      <td>100</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>97743</th>\n",
       "      <td>1703171</td>\n",
       "      <td>1311</td>\n",
       "      <td>173933</td>\n",
       "      <td>210824.0</td>\n",
       "      <td>2180-12-24</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>Magnesium Sulfate</td>\n",
       "      <td>MAGS1I</td>\n",
       "      <td>001412</td>\n",
       "      <td>7.440753e+07</td>\n",
       "      <td>1gm/2ml vial</td>\n",
       "      <td>2</td>\n",
       "      <td>gm</td>\n",
       "      <td>4</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149204</th>\n",
       "      <td>499255</td>\n",
       "      <td>2171</td>\n",
       "      <td>138417</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Furosemide</td>\n",
       "      <td>Furosemide</td>\n",
       "      <td>Furosemide</td>\n",
       "      <td>FURO40</td>\n",
       "      <td>008209</td>\n",
       "      <td>5.482992e+07</td>\n",
       "      <td>40MG TAB</td>\n",
       "      <td>60</td>\n",
       "      <td>mg</td>\n",
       "      <td>1.5</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>171014</th>\n",
       "      <td>954265</td>\n",
       "      <td>2330</td>\n",
       "      <td>175091</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2112-10-15</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>ACET325</td>\n",
       "      <td>004489</td>\n",
       "      <td>4.505013e+07</td>\n",
       "      <td>325MG TAB</td>\n",
       "      <td>325-650</td>\n",
       "      <td>mg</td>\n",
       "      <td>1-2</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>171638</th>\n",
       "      <td>954269</td>\n",
       "      <td>2330</td>\n",
       "      <td>175091</td>\n",
       "      <td>272604.0</td>\n",
       "      <td>2112-10-16</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Morphine Sulfate</td>\n",
       "      <td>Morphine Sulfate</td>\n",
       "      <td>Morphine Sulfate (1-6mg)</td>\n",
       "      <td>MORP1-6</td>\n",
       "      <td>004068</td>\n",
       "      <td>7.412610e+07</td>\n",
       "      <td>1-6MG RANGE</td>\n",
       "      <td>1-6</td>\n",
       "      <td>mg</td>\n",
       "      <td>0.1-0.6</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>183635</th>\n",
       "      <td>1965830</td>\n",
       "      <td>2602</td>\n",
       "      <td>196111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2141-02-01</td>\n",
       "      <td>NaT</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>HEPBASE</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>HEPARIN BASE</td>\n",
       "      <td>250</td>\n",
       "      <td>mL</td>\n",
       "      <td>250</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>195697</th>\n",
       "      <td>1901728</td>\n",
       "      <td>2647</td>\n",
       "      <td>127845</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2194-02-13</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Morphine Sulfate</td>\n",
       "      <td>Morphine Sulfate</td>\n",
       "      <td>Morphine Sulfate</td>\n",
       "      <td>MORP2I</td>\n",
       "      <td>004070</td>\n",
       "      <td>7.417620e+07</td>\n",
       "      <td>2mg Syringe</td>\n",
       "      <td>2</td>\n",
       "      <td>mg</td>\n",
       "      <td>1</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>195863</th>\n",
       "      <td>1901716</td>\n",
       "      <td>2647</td>\n",
       "      <td>127845</td>\n",
       "      <td>218306.0</td>\n",
       "      <td>2194-02-14</td>\n",
       "      <td>NaT</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>D5W50</td>\n",
       "      <td>001972</td>\n",
       "      <td>3.380017e+08</td>\n",
       "      <td>50ML BAG</td>\n",
       "      <td>50</td>\n",
       "      <td>mL</td>\n",
       "      <td>50</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV DRIP</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>195876</th>\n",
       "      <td>1901720</td>\n",
       "      <td>2647</td>\n",
       "      <td>127845</td>\n",
       "      <td>218306.0</td>\n",
       "      <td>2194-02-15</td>\n",
       "      <td>NaT</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>CIPROBASE</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>1 BAG</td>\n",
       "      <td>200</td>\n",
       "      <td>mL</td>\n",
       "      <td>200</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>195879</th>\n",
       "      <td>1901723</td>\n",
       "      <td>2647</td>\n",
       "      <td>127845</td>\n",
       "      <td>218306.0</td>\n",
       "      <td>2194-02-16</td>\n",
       "      <td>NaT</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>D5W100</td>\n",
       "      <td>001972</td>\n",
       "      <td>3.380017e+08</td>\n",
       "      <td>100ML BAG</td>\n",
       "      <td>100</td>\n",
       "      <td>mL</td>\n",
       "      <td>100</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV DRIP</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>343062</th>\n",
       "      <td>1845745</td>\n",
       "      <td>4844</td>\n",
       "      <td>134272</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2100-11-03</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Morphine Sulfate</td>\n",
       "      <td>Morphine Sulfate</td>\n",
       "      <td>Morphine PCA</td>\n",
       "      <td>MORP50PCA</td>\n",
       "      <td>004067</td>\n",
       "      <td>3.382690e+08</td>\n",
       "      <td>50MG/50ML SYR</td>\n",
       "      <td>1</td>\n",
       "      <td>mg</td>\n",
       "      <td>0.02</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IVPCA</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>343064</th>\n",
       "      <td>1845747</td>\n",
       "      <td>4844</td>\n",
       "      <td>134272</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2100-11-03</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>ACET325</td>\n",
       "      <td>004489</td>\n",
       "      <td>4.505013e+07</td>\n",
       "      <td>325MG TAB</td>\n",
       "      <td>650</td>\n",
       "      <td>mg</td>\n",
       "      <td>2</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>412779</th>\n",
       "      <td>1956892</td>\n",
       "      <td>5466</td>\n",
       "      <td>108815</td>\n",
       "      <td>231060.0</td>\n",
       "      <td>2130-03-03</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Heparin</td>\n",
       "      <td>Heparin</td>\n",
       "      <td>Heparin Sodium</td>\n",
       "      <td>HEPA5I</td>\n",
       "      <td>006549</td>\n",
       "      <td>6.410400e+08</td>\n",
       "      <td>5000U/ML VIAL</td>\n",
       "      <td>5000</td>\n",
       "      <td>UNIT</td>\n",
       "      <td>1</td>\n",
       "      <td>ml</td>\n",
       "      <td>SC</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>412781</th>\n",
       "      <td>1956894</td>\n",
       "      <td>5466</td>\n",
       "      <td>108815</td>\n",
       "      <td>231060.0</td>\n",
       "      <td>2130-03-03</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen (Liquid)</td>\n",
       "      <td>ACET650L</td>\n",
       "      <td>004481</td>\n",
       "      <td>5.430105e+07</td>\n",
       "      <td>650mg UDCUP</td>\n",
       "      <td>325-650</td>\n",
       "      <td>mg</td>\n",
       "      <td>0.5-1</td>\n",
       "      <td>UDCUP</td>\n",
       "      <td>NG</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>412786</th>\n",
       "      <td>1956900</td>\n",
       "      <td>5466</td>\n",
       "      <td>108815</td>\n",
       "      <td>231060.0</td>\n",
       "      <td>2130-03-03</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>DOCU100</td>\n",
       "      <td>003009</td>\n",
       "      <td>5.107900e+10</td>\n",
       "      <td>100MG CAP</td>\n",
       "      <td>100</td>\n",
       "      <td>mg</td>\n",
       "      <td>1</td>\n",
       "      <td>CAP</td>\n",
       "      <td>PO</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>450913</th>\n",
       "      <td>1956368</td>\n",
       "      <td>7065</td>\n",
       "      <td>186288</td>\n",
       "      <td>210883.0</td>\n",
       "      <td>2200-01-21</td>\n",
       "      <td>NaT</td>\n",
       "      <td>BASE</td>\n",
       "      <td>D5W</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>HEPBASE</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>HEPARIN BASE</td>\n",
       "      <td>250</td>\n",
       "      <td>mL</td>\n",
       "      <td>250</td>\n",
       "      <td>ml</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>492349</th>\n",
       "      <td>1898043</td>\n",
       "      <td>6870</td>\n",
       "      <td>167183</td>\n",
       "      <td>202608.0</td>\n",
       "      <td>2195-01-15</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>DOCU100</td>\n",
       "      <td>003009</td>\n",
       "      <td>5.107900e+10</td>\n",
       "      <td>100MG CAP</td>\n",
       "      <td>100</td>\n",
       "      <td>mg</td>\n",
       "      <td>1</td>\n",
       "      <td>CAP</td>\n",
       "      <td>PO</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>492352</th>\n",
       "      <td>1898046</td>\n",
       "      <td>6870</td>\n",
       "      <td>167183</td>\n",
       "      <td>202608.0</td>\n",
       "      <td>2195-01-15</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>ACET325</td>\n",
       "      <td>004489</td>\n",
       "      <td>4.505013e+07</td>\n",
       "      <td>325MG TAB</td>\n",
       "      <td>650</td>\n",
       "      <td>mg</td>\n",
       "      <td>2</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>494913</th>\n",
       "      <td>1898060</td>\n",
       "      <td>6870</td>\n",
       "      <td>167183</td>\n",
       "      <td>202608.0</td>\n",
       "      <td>2195-01-15</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Furosemide</td>\n",
       "      <td>Furosemide</td>\n",
       "      <td>Furosemide</td>\n",
       "      <td>FURO20</td>\n",
       "      <td>008208</td>\n",
       "      <td>5.482972e+07</td>\n",
       "      <td>20MG TAB</td>\n",
       "      <td>20</td>\n",
       "      <td>mg</td>\n",
       "      <td>1</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3239730</th>\n",
       "      <td>552397</td>\n",
       "      <td>67440</td>\n",
       "      <td>174998</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2105-08-20</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>DOCU100</td>\n",
       "      <td>3009</td>\n",
       "      <td>9.042245e+08</td>\n",
       "      <td>100mg Capsule</td>\n",
       "      <td>100</td>\n",
       "      <td>mg</td>\n",
       "      <td>1</td>\n",
       "      <td>CAP</td>\n",
       "      <td>PO</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3240526</th>\n",
       "      <td>553149</td>\n",
       "      <td>67440</td>\n",
       "      <td>174998</td>\n",
       "      <td>227580.0</td>\n",
       "      <td>2105-08-23</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>NACLFLUSH</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>Syringe</td>\n",
       "      <td>3</td>\n",
       "      <td>mL</td>\n",
       "      <td>0.6</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3240527</th>\n",
       "      <td>553150</td>\n",
       "      <td>67440</td>\n",
       "      <td>174998</td>\n",
       "      <td>227580.0</td>\n",
       "      <td>2105-08-23</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>ACET325</td>\n",
       "      <td>4489</td>\n",
       "      <td>5.107900e+10</td>\n",
       "      <td>325mg Tablet</td>\n",
       "      <td>650</td>\n",
       "      <td>mg</td>\n",
       "      <td>2</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO/NG</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3250222</th>\n",
       "      <td>349053</td>\n",
       "      <td>68037</td>\n",
       "      <td>169836</td>\n",
       "      <td>287137.0</td>\n",
       "      <td>2171-09-28</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>ACET325</td>\n",
       "      <td>004489</td>\n",
       "      <td>5.107900e+10</td>\n",
       "      <td>325mg Tablet</td>\n",
       "      <td>650</td>\n",
       "      <td>mg</td>\n",
       "      <td>2</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO/NG</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3250225</th>\n",
       "      <td>349065</td>\n",
       "      <td>68037</td>\n",
       "      <td>169836</td>\n",
       "      <td>287137.0</td>\n",
       "      <td>2171-09-29</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>NACLFLUSH</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>Syringe</td>\n",
       "      <td>3</td>\n",
       "      <td>mL</td>\n",
       "      <td>0.6</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3251027</th>\n",
       "      <td>348907</td>\n",
       "      <td>68037</td>\n",
       "      <td>169836</td>\n",
       "      <td>287137.0</td>\n",
       "      <td>2171-09-27</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Heparin</td>\n",
       "      <td>Heparin</td>\n",
       "      <td>Heparin Sodium</td>\n",
       "      <td>HEPA5I</td>\n",
       "      <td>006549</td>\n",
       "      <td>6.332303e+10</td>\n",
       "      <td>5000 Units / mL- 1mL Vial</td>\n",
       "      <td>5000</td>\n",
       "      <td>UNIT</td>\n",
       "      <td>1</td>\n",
       "      <td>mL</td>\n",
       "      <td>SC</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3537431</th>\n",
       "      <td>235118</td>\n",
       "      <td>77565</td>\n",
       "      <td>189804</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Furosemide</td>\n",
       "      <td>Furosemide</td>\n",
       "      <td>Furosemide</td>\n",
       "      <td>FURO20</td>\n",
       "      <td>008208</td>\n",
       "      <td>1.821171e+08</td>\n",
       "      <td>20mg Tablet</td>\n",
       "      <td>20</td>\n",
       "      <td>mg</td>\n",
       "      <td>1</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3537432</th>\n",
       "      <td>235112</td>\n",
       "      <td>77565</td>\n",
       "      <td>189804</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Furosemide</td>\n",
       "      <td>Furosemide</td>\n",
       "      <td>Furosemide</td>\n",
       "      <td>FURO20</td>\n",
       "      <td>008208</td>\n",
       "      <td>1.821171e+08</td>\n",
       "      <td>20mg Tablet</td>\n",
       "      <td>20</td>\n",
       "      <td>mg</td>\n",
       "      <td>1</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3625505</th>\n",
       "      <td>581168</td>\n",
       "      <td>82556</td>\n",
       "      <td>104985</td>\n",
       "      <td>278313.0</td>\n",
       "      <td>2136-06-23</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>NACLFLUSH</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>Syringe</td>\n",
       "      <td>3</td>\n",
       "      <td>mL</td>\n",
       "      <td>0.6</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3625511</th>\n",
       "      <td>581179</td>\n",
       "      <td>82556</td>\n",
       "      <td>104985</td>\n",
       "      <td>278313.0</td>\n",
       "      <td>2136-06-24</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>DOCU100</td>\n",
       "      <td>003009</td>\n",
       "      <td>9.042245e+08</td>\n",
       "      <td>100mg Capsule</td>\n",
       "      <td>100</td>\n",
       "      <td>mg</td>\n",
       "      <td>1</td>\n",
       "      <td>CAP</td>\n",
       "      <td>PO</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3625514</th>\n",
       "      <td>581173</td>\n",
       "      <td>82556</td>\n",
       "      <td>104985</td>\n",
       "      <td>278313.0</td>\n",
       "      <td>2136-06-24</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen (Liquid)</td>\n",
       "      <td>ACET650L</td>\n",
       "      <td>065758</td>\n",
       "      <td>1.210657e+08</td>\n",
       "      <td>650mg UD Cup</td>\n",
       "      <td>325-650</td>\n",
       "      <td>mg</td>\n",
       "      <td>0.5-1</td>\n",
       "      <td>UDCUP</td>\n",
       "      <td>PO/NG</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3625515</th>\n",
       "      <td>581172</td>\n",
       "      <td>82556</td>\n",
       "      <td>104985</td>\n",
       "      <td>278313.0</td>\n",
       "      <td>2136-06-24</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>ACET325</td>\n",
       "      <td>004489</td>\n",
       "      <td>5.107900e+10</td>\n",
       "      <td>325mg Tablet</td>\n",
       "      <td>325-650</td>\n",
       "      <td>mg</td>\n",
       "      <td>1-2</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO/NG</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3625516</th>\n",
       "      <td>581171</td>\n",
       "      <td>82556</td>\n",
       "      <td>104985</td>\n",
       "      <td>278313.0</td>\n",
       "      <td>2136-06-24</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>NACLFLUSH</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>Syringe</td>\n",
       "      <td>10</td>\n",
       "      <td>mL</td>\n",
       "      <td>2</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3627122</th>\n",
       "      <td>580462</td>\n",
       "      <td>82556</td>\n",
       "      <td>104985</td>\n",
       "      <td>278313.0</td>\n",
       "      <td>2136-06-21</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Heparin</td>\n",
       "      <td>Heparin</td>\n",
       "      <td>Heparin Sodium</td>\n",
       "      <td>HEPA5I</td>\n",
       "      <td>006549</td>\n",
       "      <td>6.332303e+10</td>\n",
       "      <td>5000 Units / mL- 1mL Vial</td>\n",
       "      <td>5000</td>\n",
       "      <td>UNIT</td>\n",
       "      <td>1</td>\n",
       "      <td>mL</td>\n",
       "      <td>SC</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3627125</th>\n",
       "      <td>581158</td>\n",
       "      <td>82556</td>\n",
       "      <td>104985</td>\n",
       "      <td>278313.0</td>\n",
       "      <td>2136-06-21</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>NACLFLUSH</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>Syringe</td>\n",
       "      <td>10</td>\n",
       "      <td>mL</td>\n",
       "      <td>2</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3627127</th>\n",
       "      <td>580466</td>\n",
       "      <td>82556</td>\n",
       "      <td>104985</td>\n",
       "      <td>278313.0</td>\n",
       "      <td>2136-06-21</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>NACLFLUSH</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>Syringe</td>\n",
       "      <td>3</td>\n",
       "      <td>mL</td>\n",
       "      <td>0.6</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3656886</th>\n",
       "      <td>4070675</td>\n",
       "      <td>80359</td>\n",
       "      <td>194195</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Insulin</td>\n",
       "      <td>Insulin</td>\n",
       "      <td>Insulin Glargine</td>\n",
       "      <td>GLAR100I</td>\n",
       "      <td>047780</td>\n",
       "      <td>8.822203e+07</td>\n",
       "      <td>100 Units / mL - 10 mL Vial</td>\n",
       "      <td>30</td>\n",
       "      <td>UNIT</td>\n",
       "      <td>0.026</td>\n",
       "      <td>VIAL</td>\n",
       "      <td>SC</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3656887</th>\n",
       "      <td>4070676</td>\n",
       "      <td>80359</td>\n",
       "      <td>194195</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Insulin</td>\n",
       "      <td>Insulin</td>\n",
       "      <td>Insulin - Sliding Scale</td>\n",
       "      <td>INSULIN</td>\n",
       "      <td>027413</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>Dummy Package for Sliding Scale</td>\n",
       "      <td>0</td>\n",
       "      <td>UNIT</td>\n",
       "      <td>0</td>\n",
       "      <td>VIAL</td>\n",
       "      <td>SC</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3738879</th>\n",
       "      <td>628386</td>\n",
       "      <td>85710</td>\n",
       "      <td>133342</td>\n",
       "      <td>282440.0</td>\n",
       "      <td>2160-05-18</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Heparin</td>\n",
       "      <td>Heparin</td>\n",
       "      <td>Heparin Sodium</td>\n",
       "      <td>HEPA5I</td>\n",
       "      <td>006549</td>\n",
       "      <td>6.332303e+10</td>\n",
       "      <td>5000 Units / mL- 1mL Vial</td>\n",
       "      <td>5000</td>\n",
       "      <td>UNIT</td>\n",
       "      <td>1</td>\n",
       "      <td>mL</td>\n",
       "      <td>SC</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3749729</th>\n",
       "      <td>628413</td>\n",
       "      <td>85710</td>\n",
       "      <td>133342</td>\n",
       "      <td>282440.0</td>\n",
       "      <td>2160-05-21</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>NACLFLUSH</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>Syringe</td>\n",
       "      <td>3</td>\n",
       "      <td>mL</td>\n",
       "      <td>0.6</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3749731</th>\n",
       "      <td>628415</td>\n",
       "      <td>85710</td>\n",
       "      <td>133342</td>\n",
       "      <td>282440.0</td>\n",
       "      <td>2160-05-22</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>APAP500</td>\n",
       "      <td>004490</td>\n",
       "      <td>9.041989e+08</td>\n",
       "      <td>500mg Tablet</td>\n",
       "      <td>1000</td>\n",
       "      <td>mg</td>\n",
       "      <td>2</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO/NG</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4005568</th>\n",
       "      <td>1529401</td>\n",
       "      <td>95230</td>\n",
       "      <td>192633</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2183-11-20</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>NACLFLUSH</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>Syringe</td>\n",
       "      <td>3</td>\n",
       "      <td>mL</td>\n",
       "      <td>0.6</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4005573</th>\n",
       "      <td>1529406</td>\n",
       "      <td>95230</td>\n",
       "      <td>192633</td>\n",
       "      <td>210969.0</td>\n",
       "      <td>2183-11-21</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>Docusate Sodium</td>\n",
       "      <td>DOCU100</td>\n",
       "      <td>003009</td>\n",
       "      <td>9.042245e+08</td>\n",
       "      <td>100mg Capsule</td>\n",
       "      <td>100</td>\n",
       "      <td>mg</td>\n",
       "      <td>1</td>\n",
       "      <td>CAP</td>\n",
       "      <td>PO</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4005574</th>\n",
       "      <td>1529407</td>\n",
       "      <td>95230</td>\n",
       "      <td>192633</td>\n",
       "      <td>210969.0</td>\n",
       "      <td>2183-11-21</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>Sodium Chloride 0.9%  Flush</td>\n",
       "      <td>NACLFLUSH</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>Syringe</td>\n",
       "      <td>3</td>\n",
       "      <td>mL</td>\n",
       "      <td>0.6</td>\n",
       "      <td>SYR</td>\n",
       "      <td>IV</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4017183</th>\n",
       "      <td>1529416</td>\n",
       "      <td>95230</td>\n",
       "      <td>192633</td>\n",
       "      <td>210969.0</td>\n",
       "      <td>2183-11-22</td>\n",
       "      <td>NaT</td>\n",
       "      <td>MAIN</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>Acetaminophen</td>\n",
       "      <td>ACET325</td>\n",
       "      <td>004489</td>\n",
       "      <td>5.107900e+10</td>\n",
       "      <td>325mg Tablet</td>\n",
       "      <td>650</td>\n",
       "      <td>mg</td>\n",
       "      <td>2</td>\n",
       "      <td>TAB</td>\n",
       "      <td>PO/NG</td>\n",
       "      <td>NaT</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>131 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          ROW_ID  SUBJECT_ID  HADM_ID  ICUSTAY_ID  STARTDATE ENDDATE  \\\n",
       "34263    1235214         458   183288    279940.0 2152-01-24     NaT   \n",
       "34264    1235208         458   183288    279940.0 2152-01-24     NaT   \n",
       "71447    1926835         979   163886         NaN 2163-02-25     NaT   \n",
       "95226    1703181        1311   173933    210824.0 2180-12-25     NaT   \n",
       "96026     599638        1329   139888         NaN 2152-09-19     NaT   \n",
       "96824     599648        1329   139888    297865.0 2152-09-22     NaT   \n",
       "96867     599657        1329   139888    295636.0 2152-09-26     NaT   \n",
       "97743    1703171        1311   173933    210824.0 2180-12-24     NaT   \n",
       "149204    499255        2171   138417         NaN        NaT     NaT   \n",
       "171014    954265        2330   175091         NaN 2112-10-15     NaT   \n",
       "171638    954269        2330   175091    272604.0 2112-10-16     NaT   \n",
       "183635   1965830        2602   196111         NaN 2141-02-01     NaT   \n",
       "195697   1901728        2647   127845         NaN 2194-02-13     NaT   \n",
       "195863   1901716        2647   127845    218306.0 2194-02-14     NaT   \n",
       "195876   1901720        2647   127845    218306.0 2194-02-15     NaT   \n",
       "195879   1901723        2647   127845    218306.0 2194-02-16     NaT   \n",
       "343062   1845745        4844   134272         NaN 2100-11-03     NaT   \n",
       "343064   1845747        4844   134272         NaN 2100-11-03     NaT   \n",
       "412779   1956892        5466   108815    231060.0 2130-03-03     NaT   \n",
       "412781   1956894        5466   108815    231060.0 2130-03-03     NaT   \n",
       "412786   1956900        5466   108815    231060.0 2130-03-03     NaT   \n",
       "450913   1956368        7065   186288    210883.0 2200-01-21     NaT   \n",
       "492349   1898043        6870   167183    202608.0 2195-01-15     NaT   \n",
       "492352   1898046        6870   167183    202608.0 2195-01-15     NaT   \n",
       "494913   1898060        6870   167183    202608.0 2195-01-15     NaT   \n",
       "...          ...         ...      ...         ...        ...     ...   \n",
       "3239730   552397       67440   174998         NaN 2105-08-20     NaT   \n",
       "3240526   553149       67440   174998    227580.0 2105-08-23     NaT   \n",
       "3240527   553150       67440   174998    227580.0 2105-08-23     NaT   \n",
       "3250222   349053       68037   169836    287137.0 2171-09-28     NaT   \n",
       "3250225   349065       68037   169836    287137.0 2171-09-29     NaT   \n",
       "3251027   348907       68037   169836    287137.0 2171-09-27     NaT   \n",
       "3537431   235118       77565   189804         NaN        NaT     NaT   \n",
       "3537432   235112       77565   189804         NaN        NaT     NaT   \n",
       "3625505   581168       82556   104985    278313.0 2136-06-23     NaT   \n",
       "3625511   581179       82556   104985    278313.0 2136-06-24     NaT   \n",
       "3625514   581173       82556   104985    278313.0 2136-06-24     NaT   \n",
       "3625515   581172       82556   104985    278313.0 2136-06-24     NaT   \n",
       "3625516   581171       82556   104985    278313.0 2136-06-24     NaT   \n",
       "3627122   580462       82556   104985    278313.0 2136-06-21     NaT   \n",
       "3627125   581158       82556   104985    278313.0 2136-06-21     NaT   \n",
       "3627127   580466       82556   104985    278313.0 2136-06-21     NaT   \n",
       "3656886  4070675       80359   194195         NaN        NaT     NaT   \n",
       "3656887  4070676       80359   194195         NaN        NaT     NaT   \n",
       "3738879   628386       85710   133342    282440.0 2160-05-18     NaT   \n",
       "3749729   628413       85710   133342    282440.0 2160-05-21     NaT   \n",
       "3749731   628415       85710   133342    282440.0 2160-05-22     NaT   \n",
       "4005568  1529401       95230   192633         NaN 2183-11-20     NaT   \n",
       "4005573  1529406       95230   192633    210969.0 2183-11-21     NaT   \n",
       "4005574  1529407       95230   192633    210969.0 2183-11-21     NaT   \n",
       "4017183  1529416       95230   192633    210969.0 2183-11-22     NaT   \n",
       "\n",
       "        DRUG_TYPE                         DRUG                DRUG_NAME_POE  \\\n",
       "34263        MAIN                      Insulin                      Insulin   \n",
       "34264        MAIN                      Insulin                      Insulin   \n",
       "71447        BASE                          D5W                          NaN   \n",
       "95226        MAIN             Morphine Sulfate             Morphine Sulfate   \n",
       "96026        BASE                          D5W                          NaN   \n",
       "96824        BASE                          D5W                          NaN   \n",
       "96867        BASE                          D5W                          NaN   \n",
       "97743        MAIN            Magnesium Sulfate            Magnesium Sulfate   \n",
       "149204       MAIN                   Furosemide                   Furosemide   \n",
       "171014       MAIN                Acetaminophen                Acetaminophen   \n",
       "171638       MAIN             Morphine Sulfate             Morphine Sulfate   \n",
       "183635       BASE                          D5W                          NaN   \n",
       "195697       MAIN             Morphine Sulfate             Morphine Sulfate   \n",
       "195863       BASE                          D5W                          NaN   \n",
       "195876       BASE                          D5W                          NaN   \n",
       "195879       BASE                          D5W                          NaN   \n",
       "343062       MAIN             Morphine Sulfate             Morphine Sulfate   \n",
       "343064       MAIN                Acetaminophen                Acetaminophen   \n",
       "412779       MAIN                      Heparin                      Heparin   \n",
       "412781       MAIN                Acetaminophen                Acetaminophen   \n",
       "412786       MAIN              Docusate Sodium              Docusate Sodium   \n",
       "450913       BASE                          D5W                          NaN   \n",
       "492349       MAIN              Docusate Sodium              Docusate Sodium   \n",
       "492352       MAIN                Acetaminophen                Acetaminophen   \n",
       "494913       MAIN                   Furosemide                   Furosemide   \n",
       "...           ...                          ...                          ...   \n",
       "3239730      MAIN              Docusate Sodium              Docusate Sodium   \n",
       "3240526      MAIN  Sodium Chloride 0.9%  Flush  Sodium Chloride 0.9%  Flush   \n",
       "3240527      MAIN                Acetaminophen                Acetaminophen   \n",
       "3250222      MAIN                Acetaminophen                Acetaminophen   \n",
       "3250225      MAIN  Sodium Chloride 0.9%  Flush  Sodium Chloride 0.9%  Flush   \n",
       "3251027      MAIN                      Heparin                      Heparin   \n",
       "3537431      MAIN                   Furosemide                   Furosemide   \n",
       "3537432      MAIN                   Furosemide                   Furosemide   \n",
       "3625505      MAIN  Sodium Chloride 0.9%  Flush  Sodium Chloride 0.9%  Flush   \n",
       "3625511      MAIN              Docusate Sodium              Docusate Sodium   \n",
       "3625514      MAIN                Acetaminophen                Acetaminophen   \n",
       "3625515      MAIN                Acetaminophen                Acetaminophen   \n",
       "3625516      MAIN  Sodium Chloride 0.9%  Flush  Sodium Chloride 0.9%  Flush   \n",
       "3627122      MAIN                      Heparin                      Heparin   \n",
       "3627125      MAIN  Sodium Chloride 0.9%  Flush  Sodium Chloride 0.9%  Flush   \n",
       "3627127      MAIN  Sodium Chloride 0.9%  Flush  Sodium Chloride 0.9%  Flush   \n",
       "3656886      MAIN                      Insulin                      Insulin   \n",
       "3656887      MAIN                      Insulin                      Insulin   \n",
       "3738879      MAIN                      Heparin                      Heparin   \n",
       "3749729      MAIN  Sodium Chloride 0.9%  Flush  Sodium Chloride 0.9%  Flush   \n",
       "3749731      MAIN                Acetaminophen                Acetaminophen   \n",
       "4005568      MAIN  Sodium Chloride 0.9%  Flush  Sodium Chloride 0.9%  Flush   \n",
       "4005573      MAIN              Docusate Sodium              Docusate Sodium   \n",
       "4005574      MAIN  Sodium Chloride 0.9%  Flush  Sodium Chloride 0.9%  Flush   \n",
       "4017183      MAIN                Acetaminophen                Acetaminophen   \n",
       "\n",
       "                   DRUG_NAME_GENERIC FORMULARY_DRUG_CD     GSN           NDC  \\\n",
       "34263                        Insulin           INSULIN  001723  0.000000e+00   \n",
       "34264                        Insulin           INSULIN  001723  0.000000e+00   \n",
       "71447                            NaN          CLINBASE     NaN  0.000000e+00   \n",
       "95226               Morphine Sulfate            MORP4I  004072  7.412580e+07   \n",
       "96026                            NaN           HEPBASE     NaN  0.000000e+00   \n",
       "96824                            NaN            D5W100  001972  3.380017e+08   \n",
       "96867                            NaN            D5W100  001972  3.380017e+08   \n",
       "97743              Magnesium Sulfate            MAGS1I  001412  7.440753e+07   \n",
       "149204                    Furosemide            FURO40  008209  5.482992e+07   \n",
       "171014                 Acetaminophen           ACET325  004489  4.505013e+07   \n",
       "171638      Morphine Sulfate (1-6mg)           MORP1-6  004068  7.412610e+07   \n",
       "183635                           NaN           HEPBASE     NaN  0.000000e+00   \n",
       "195697              Morphine Sulfate            MORP2I  004070  7.417620e+07   \n",
       "195863                           NaN             D5W50  001972  3.380017e+08   \n",
       "195876                           NaN         CIPROBASE     NaN  0.000000e+00   \n",
       "195879                           NaN            D5W100  001972  3.380017e+08   \n",
       "343062                  Morphine PCA         MORP50PCA  004067  3.382690e+08   \n",
       "343064                 Acetaminophen           ACET325  004489  4.505013e+07   \n",
       "412779                Heparin Sodium            HEPA5I  006549  6.410400e+08   \n",
       "412781        Acetaminophen (Liquid)          ACET650L  004481  5.430105e+07   \n",
       "412786               Docusate Sodium           DOCU100  003009  5.107900e+10   \n",
       "450913                           NaN           HEPBASE     NaN  0.000000e+00   \n",
       "492349               Docusate Sodium           DOCU100  003009  5.107900e+10   \n",
       "492352                 Acetaminophen           ACET325  004489  4.505013e+07   \n",
       "494913                    Furosemide            FURO20  008208  5.482972e+07   \n",
       "...                              ...               ...     ...           ...   \n",
       "3239730              Docusate Sodium           DOCU100    3009  9.042245e+08   \n",
       "3240526  Sodium Chloride 0.9%  Flush         NACLFLUSH     NaN  0.000000e+00   \n",
       "3240527                Acetaminophen           ACET325    4489  5.107900e+10   \n",
       "3250222                Acetaminophen           ACET325  004489  5.107900e+10   \n",
       "3250225  Sodium Chloride 0.9%  Flush         NACLFLUSH     NaN  0.000000e+00   \n",
       "3251027               Heparin Sodium            HEPA5I  006549  6.332303e+10   \n",
       "3537431                   Furosemide            FURO20  008208  1.821171e+08   \n",
       "3537432                   Furosemide            FURO20  008208  1.821171e+08   \n",
       "3625505  Sodium Chloride 0.9%  Flush         NACLFLUSH     NaN  0.000000e+00   \n",
       "3625511              Docusate Sodium           DOCU100  003009  9.042245e+08   \n",
       "3625514       Acetaminophen (Liquid)          ACET650L  065758  1.210657e+08   \n",
       "3625515                Acetaminophen           ACET325  004489  5.107900e+10   \n",
       "3625516  Sodium Chloride 0.9%  Flush         NACLFLUSH     NaN  0.000000e+00   \n",
       "3627122               Heparin Sodium            HEPA5I  006549  6.332303e+10   \n",
       "3627125  Sodium Chloride 0.9%  Flush         NACLFLUSH     NaN  0.000000e+00   \n",
       "3627127  Sodium Chloride 0.9%  Flush         NACLFLUSH     NaN  0.000000e+00   \n",
       "3656886             Insulin Glargine          GLAR100I  047780  8.822203e+07   \n",
       "3656887      Insulin - Sliding Scale           INSULIN  027413  0.000000e+00   \n",
       "3738879               Heparin Sodium            HEPA5I  006549  6.332303e+10   \n",
       "3749729  Sodium Chloride 0.9%  Flush         NACLFLUSH     NaN  0.000000e+00   \n",
       "3749731                Acetaminophen           APAP500  004490  9.041989e+08   \n",
       "4005568  Sodium Chloride 0.9%  Flush         NACLFLUSH     NaN  0.000000e+00   \n",
       "4005573              Docusate Sodium           DOCU100  003009  9.042245e+08   \n",
       "4005574  Sodium Chloride 0.9%  Flush         NACLFLUSH     NaN  0.000000e+00   \n",
       "4017183                Acetaminophen           ACET325  004489  5.107900e+10   \n",
       "\n",
       "                                      PROD_STRENGTH DOSE_VAL_RX DOSE_UNIT_RX  \\\n",
       "34263    Dummy Pkg for POE pump and PHA SS ordering           0         UNIT   \n",
       "34264    Dummy Pkg for POE pump and PHA SS ordering           0         UNIT   \n",
       "71447                                      50ML BAG          50           mL   \n",
       "95226                                   4mg Syringe         2-5           mg   \n",
       "96026                                  HEPARIN BASE         250           mL   \n",
       "96824                                     100ML BAG         100           mL   \n",
       "96867                                     100ML BAG         100           mL   \n",
       "97743                                  1gm/2ml vial           2           gm   \n",
       "149204                                     40MG TAB          60           mg   \n",
       "171014                                    325MG TAB     325-650           mg   \n",
       "171638                                  1-6MG RANGE         1-6           mg   \n",
       "183635                                 HEPARIN BASE         250           mL   \n",
       "195697                                  2mg Syringe           2           mg   \n",
       "195863                                     50ML BAG          50           mL   \n",
       "195876                                        1 BAG         200           mL   \n",
       "195879                                    100ML BAG         100           mL   \n",
       "343062                                50MG/50ML SYR           1           mg   \n",
       "343064                                    325MG TAB         650           mg   \n",
       "412779                                5000U/ML VIAL        5000         UNIT   \n",
       "412781                                  650mg UDCUP     325-650           mg   \n",
       "412786                                    100MG CAP         100           mg   \n",
       "450913                                 HEPARIN BASE         250           mL   \n",
       "492349                                    100MG CAP         100           mg   \n",
       "492352                                    325MG TAB         650           mg   \n",
       "494913                                     20MG TAB          20           mg   \n",
       "...                                             ...         ...          ...   \n",
       "3239730                               100mg Capsule         100           mg   \n",
       "3240526                                     Syringe           3           mL   \n",
       "3240527                                325mg Tablet         650           mg   \n",
       "3250222                                325mg Tablet         650           mg   \n",
       "3250225                                     Syringe           3           mL   \n",
       "3251027                   5000 Units / mL- 1mL Vial        5000         UNIT   \n",
       "3537431                                 20mg Tablet          20           mg   \n",
       "3537432                                 20mg Tablet          20           mg   \n",
       "3625505                                     Syringe           3           mL   \n",
       "3625511                               100mg Capsule         100           mg   \n",
       "3625514                                650mg UD Cup     325-650           mg   \n",
       "3625515                                325mg Tablet     325-650           mg   \n",
       "3625516                                     Syringe          10           mL   \n",
       "3627122                   5000 Units / mL- 1mL Vial        5000         UNIT   \n",
       "3627125                                     Syringe          10           mL   \n",
       "3627127                                     Syringe           3           mL   \n",
       "3656886                 100 Units / mL - 10 mL Vial          30         UNIT   \n",
       "3656887             Dummy Package for Sliding Scale           0         UNIT   \n",
       "3738879                   5000 Units / mL- 1mL Vial        5000         UNIT   \n",
       "3749729                                     Syringe           3           mL   \n",
       "3749731                                500mg Tablet        1000           mg   \n",
       "4005568                                     Syringe           3           mL   \n",
       "4005573                               100mg Capsule         100           mg   \n",
       "4005574                                     Syringe           3           mL   \n",
       "4017183                                325mg Tablet         650           mg   \n",
       "\n",
       "        FORM_VAL_DISP FORM_UNIT_DISP    ROUTE ELAPSED_TIME  ELAPSED_DAYS  \n",
       "34263              00           VIAL       SC          NaT           NaN  \n",
       "34264              00           VIAL       SC          NaT           NaN  \n",
       "71447               1            BAG       IV          NaT           NaN  \n",
       "95226        0.5-1.25            SYR       IV          NaT           NaN  \n",
       "96026             250             ml       IV          NaT           NaN  \n",
       "96824             100             ml       IV          NaT           NaN  \n",
       "96867             100             ml       IV          NaT           NaN  \n",
       "97743               4             ml       IV          NaT           NaN  \n",
       "149204            1.5            TAB       PO          NaT           NaN  \n",
       "171014            1-2            TAB       PO          NaT           NaN  \n",
       "171638        0.1-0.6            SYR       IV          NaT           NaN  \n",
       "183635            250             ml       IV          NaT           NaN  \n",
       "195697              1            SYR       IV          NaT           NaN  \n",
       "195863             50             ml  IV DRIP          NaT           NaN  \n",
       "195876            200             ml       IV          NaT           NaN  \n",
       "195879            100             ml  IV DRIP          NaT           NaN  \n",
       "343062           0.02            SYR    IVPCA          NaT           NaN  \n",
       "343064              2            TAB       PO          NaT           NaN  \n",
       "412779              1             ml       SC          NaT           NaN  \n",
       "412781          0.5-1          UDCUP       NG          NaT           NaN  \n",
       "412786              1            CAP       PO          NaT           NaN  \n",
       "450913            250             ml       IV          NaT           NaN  \n",
       "492349              1            CAP       PO          NaT           NaN  \n",
       "492352              2            TAB       PO          NaT           NaN  \n",
       "494913              1            TAB       PO          NaT           NaN  \n",
       "...               ...            ...      ...          ...           ...  \n",
       "3239730             1            CAP       PO          NaT           NaN  \n",
       "3240526           0.6            SYR       IV          NaT           NaN  \n",
       "3240527             2            TAB    PO/NG          NaT           NaN  \n",
       "3250222             2            TAB    PO/NG          NaT           NaN  \n",
       "3250225           0.6            SYR       IV          NaT           NaN  \n",
       "3251027             1             mL       SC          NaT           NaN  \n",
       "3537431             1            TAB       PO          NaT           NaN  \n",
       "3537432             1            TAB       PO          NaT           NaN  \n",
       "3625505           0.6            SYR       IV          NaT           NaN  \n",
       "3625511             1            CAP       PO          NaT           NaN  \n",
       "3625514         0.5-1          UDCUP    PO/NG          NaT           NaN  \n",
       "3625515           1-2            TAB    PO/NG          NaT           NaN  \n",
       "3625516             2            SYR       IV          NaT           NaN  \n",
       "3627122             1             mL       SC          NaT           NaN  \n",
       "3627125             2            SYR       IV          NaT           NaN  \n",
       "3627127           0.6            SYR       IV          NaT           NaN  \n",
       "3656886         0.026           VIAL       SC          NaT           NaN  \n",
       "3656887             0           VIAL       SC          NaT           NaN  \n",
       "3738879             1             mL       SC          NaT           NaN  \n",
       "3749729           0.6            SYR       IV          NaT           NaN  \n",
       "3749731             2            TAB    PO/NG          NaT           NaN  \n",
       "4005568           0.6            SYR       IV          NaT           NaN  \n",
       "4005573             1            CAP       PO          NaT           NaN  \n",
       "4005574           0.6            SYR       IV          NaT           NaN  \n",
       "4017183             2            TAB    PO/NG          NaT           NaN  \n",
       "\n",
       "[131 rows x 21 columns]"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "presc2.loc[presc2[\"ELAPSED_DAYS\"].isnull()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
